<template>
  <div class="cartBox wap">
    <x-header :left-options="{backText: '',preventGoBack:true}" @on-click-back="goHomePage">
      <span>购物车</span>
      <a
        class="editBtn"
        v-if="!isEdit"
        slot="right"
        @click="editInit()"
        href="javascript:void(0);"
      >编辑</a>
      <a
        class="editBtn"
        v-if="isEdit"
        slot="right"
        @click="editInit()"
        href="javascript:void(0);"
      >完成</a>
    </x-header>

    <div class="cartList main">
      <scroller ref="cart_scroller">
        <div>
          <div
            class="emptyData"
            v-if="!cartInfo.shoppingCartVOList||cartInfo.shoppingCartVOList.length==0"
          >
            <img class="img" src="../../assets/img/cart/icon_notgoods.png" />
            <div class>您还没有添加任何商品</div>
            <!--<div class="go" @click="goToHome()"><span>去看看</span></div>-->
          </div>

          <div class="list" v-for="(good,index) in cartInfo.shoppingCartVOList" :key="index">
            <div class="leader" v-if="index==0">
              <!--<check-icon ></check-icon>-->
              <img class="img" src="./../../assets/img/cart/shop.png" />
              <span>{{shopInfo.name}}</span>
            </div>
            <div
              class="goodsBox"
              :class="good.goodsVO.state==0||good.goodsVO.goodsState==0?'invalidiBox':null"
            >
              <swipeout>
                <swipeout-item
                  ref="swipeoutItem"
                  transition-mode="follow"
                  :auto-close-on-button-click="true"
                >
                  <div slot="right-menu">
                    <swipeout-button @click.native="onDel(good)" type="warn">删除</swipeout-button>
                  </div>
                  <div slot="content">
                    <div class="itemBox" @click="goDetail(good)">
                      <span
                        class="invalidTip"
                        v-if="good.goodsVO.state==0||good.goodsVO.goodsState==0"
                      >失效</span>
                      <!--<span class="invalidTip" v-if="good.goodsVO.enquiry==1&&good.goodsVO.state!=0&&good.goodsVO.goodsState!=0">询价</span>-->
                      <check-icon
                        v-if="good.goodsVO.state==1&&good.goodsVO.goodsState==1"
                        :value.sync="good.checked"
                        @click.native.stop="setGoodCheck(good)"
                      ></check-icon>
                      <img
                        class="img"
                        :src="good.goodsVO.defaultPhoto?yasuo(good.goodsVO.defaultPhoto):require('../../assets/logo.png')"
                      />
                      <div class="rtCon">
                        <div class="title">[{{good.brandName}}]{{good.goodsName}}</div>
                        <div class="tagBox">
                          <span class="tag">{{good.spec}}</span>
                        </div>
                        <div class="priceBox">
                          <span
                            class="price"
                            v-if="good.goodsVO.enquiry==0"
                          >&yen;{{good.currentPrice || '询价'}}</span>
                          <span class="price" v-if="good.goodsVO.enquiry==1">询价</span>
                          <!--<x-number class="numBox" width="40px" v-model="good.num" :min="0"-->
                          <!--@on-change="change"></x-number>-->
                          <AddReduceBtn
                            v-if="good.goodsVO.state==1&&good.goodsVO.goodsState==1"
                            class="numBox"
                            :goodId="good.goodsId"
                            @updateStcok="updateStock($event)"
                            @update="countNum($event)"
                            @deleteGood="onDel(good)"
                            :item="good"
                          ></AddReduceBtn>
                          <div
                            v-if="good.goodsVO.state==0||good.goodsVO.goodsState==0"
                            class="numBox"
                          >已下架</div>
                        </div>
                        <!--<div class="redTip" v-if="good.currentDiscountActivityGoods&&good.currentPrice!=good.currentDiscountActivityGoods.taxPrice">已恢复原价</div>-->
                        <div
                          class="redTip"
                          v-if="good.taxPrice&&good.currentPrice!=good.taxPrice"
                        >价格已变动</div>

                        <p
                          v-if="good.currentDiscountActivityGoods&&good.currentDiscountActivityGoods.limitNum"
                          style="font-size: 11px;color:#FFAB91"
                        >
                          <!--优惠限{{good.currentDiscountActivityGoods.limitNum}}{{good.currentDiscountActivityGoods?good.unitName:''}},-->
                          第{{good.currentDiscountActivityGoods.limitNum+1}}{{good.currentDiscountActivityGoods?good.unitName:''}}起
                          ￥{{good.currentNormalPrice}}/{{good.currentDiscountActivityGoods?good.unitName:''}}
                        </p>
                      </div>
                    </div>

                    <div
                      style="display: flex;flex-direction: row;align-items: center;justify-content: flex-end;color:#333333"
                      v-if="good.currentFullGiftActivityGoods&&good.giftInfo"
                    >
                      <span style="color:red;margin-right: .1rem;">赠:</span>
                      <span>[{{good.giftInfo.brandName}}]{{good.giftInfo.goodsName}}</span>
                      <span
                        style="margin-left: .1rem;"
                        v-if="good.giftInfo.normalGoodsPrice"
                      >¥{{good.giftInfo.normalGoodsPrice}}/{{good.giftInfo.unitName}}</span>
                      <span style="margin-left: .2rem;color:#999999">X{{good.giftInfo.giftNum}}</span>
                    </div>
                  </div>
                </swipeout-item>
              </swipeout>
            </div>
          </div>
        </div>
      </scroller>
    </div>

    <div class="cartBottom">
      <check-icon class="checkeAllBtn" :value.sync="isAllCheck" @click.native="setAllCheckBt()">全选</check-icon>

      <div v-if="!isEdit" class="right-box">
        <div class="ct">
          <div>
            <span>合计：</span>
            <span>&yen;{{account}}</span>
          </div>
          <!--<div class="sub">红包抵扣：&yen;500</div>-->
        </div>
        <div class="countBtn" @click="commit">去结算</div>
      </div>
      <div v-if="isEdit" class="right-box">
        <div class="btnBox">
          <div class="clearBtn" @click="deleteDownGood">清理已下架商品</div>
          <div class="delBtn" @click="deleteCheckGood">删除</div>
        </div>
      </div>
    </div>

    <!--<div v-transfer-dom>-->
    <!--<confirm v-model="confirmData.show"-->
    <!--title=""-->
    <!--@on-cancel="onCancel"-->
    <!--@on-confirm="confirmData.onConfirm">-->
    <!--<p style="text-align:center;">{{confirmData.title}}</p>-->
    <!--</confirm>-->
    <!--</div>-->
  </div>
</template>

<script src="./cart.js">
</script>
<style lang="less" scoped>
@import "cart";
</style>


